package main

import (
	"encoding/json"
	"fmt"
	"go_spider_api/models"
	"io/ioutil"
	"log"
	"net/http"
)

func main() {
	client := &http.Client{}
	req, err := http.NewRequest("GET", "http://192.168.0.7:9996/listjobs.json?project=shiji", nil)
	if err != nil {
		log.Fatal(err)
	}
	req.Header.Set("User-Agent", "Apipost client Runtime/+https://www.apipost.cn/")
	resp, err := client.Do(req)
	if err != nil {
		log.Fatal(err)
	}
	bodyText, err := ioutil.ReadAll(resp.Body)
	if err != nil {
		log.Fatal(err)
	}
	fmt.Printf("%s\n", bodyText)
	var res models.JobList
	err = json.Unmarshal(bodyText, &res)
	fmt.Printf("%#v", res)
}
